package com.iterator.controller.web.marketManager;



import com.iterator.bean.web.pojo.BaseRespVo;
import com.iterator.bean.web.wy.issue.Issue;
import com.iterator.bean.web.wy.create.CreateBO;
import com.iterator.bean.web.wy.issue.IssueVO;
import com.iterator.service.web.marketManager.IssueService;
import com.iterator.util.StringTrim;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Silence_W
 * @date: 2021-01-10 11:42
 *
 * 商场管理
 *  通用问题
 **/
@RestController
@RequestMapping("admin/issue")
public class IssueController {
    @Autowired
    IssueService issueService;

    //问答数据显示
    @RequestMapping("list")
    @RequiresPermissions("admin:issue:list")
    public BaseRespVo list(Integer page, Integer limit , String question, String sort, String order){
        String trim = StringTrim.trim(question);
        IssueVO issueVO =issueService.queryIssue(page,limit,trim,sort,order);
        return BaseRespVo.ok(issueVO);
    }

    //新增问答数据
    @RequestMapping("create")
    @RequiresPermissions("admin:issue:create")
    public BaseRespVo create(@RequestBody CreateBO createBO){
       Issue issue = issueService.insertIssue(createBO);

       return BaseRespVo.ok(issue);

    }


    //更新问答数据
    @RequestMapping("update")
    @RequiresPermissions("admin:issue:update")
    public BaseRespVo update(@RequestBody Issue issue){
        Issue issue1 =  issueService.update(issue);
        return BaseRespVo.ok(issue1);
    }


    //删除问答数据
    @RequestMapping("delete")
    @RequiresPermissions("admin:issue:delete")
    public BaseRespVo delete(@RequestBody Issue issue){
        issueService.delete(issue);
        return BaseRespVo.ok();
    }
}
